home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 May: Tool Chest / Dev.CD May 98 TC.toast / Tool Chest / Development Kits / HyperCard Related / APDA HyperCard Toolkits / HyperCard Serial Toolkit 2.6 / Source Code / killSPort.p < prev    next >
Encoding:
Text File  |  1995-02-07  |  1.6 KB  |  69 lines  |  [TEXT/MPS ]

  1. (*
  2.     killSPort in/out/both -- Kill I/O on the current serial port. If the parameter is "in", then kill
  3.         the input; if the parameter is "out" then kill the output; otherwise kill both.
  4.  
  5.     To compile and link this file using Macintosh Programmer's Workshop,
  6.  
  7.         pascal -w killSPort.p
  8.         link -m ENTRYPOINT -o HyperCommands -rt XCMD=7032 -sn Main=killSPort ∂
  9.             killSPort.p.o "{MPW}"Libraries:interface.o "{MPW}"Libraries:Libraries:HyperXLib.o
  10.  
  11.     © Copyright 1987,88,89 by Apple Computer, Inc.
  12.  
  13.     Initial coding 9/87 by Harry R. Chesley.
  14. *)
  15.  
  16. {$R-}
  17.  
  18. {$S killSPort }     { Segment name must be the same as the command name. }
  19.  
  20. unit DummyUnit;
  21.  
  22. interface
  23.  
  24. uses MemTypes, QuickDraw, OSIntf, HyperXCmd;
  25.  
  26. procedure EntryPoint(paramPtr: XCmdPtr);
  27.     
  28. implementation
  29.  
  30. procedure killSPort(paramPtr: XCmdPtr); forward;
  31.  
  32. procedure EntryPoint(paramPtr: XCmdPtr);
  33.  
  34.     begin
  35.         killSPort(paramPtr);
  36.     end;
  37.  
  38. procedure killSPort(paramPtr: XCmdPtr);
  39.  
  40.     var inOutBoth: Str255;
  41.  
  42.     procedure Fail(errMsg: Str255); { set theResult and quit }
  43.         begin
  44.             paramPtr^.returnValue := PasToZero(paramPtr,errMsg);
  45.             exit(killSPort);
  46.         end;
  47.  
  48.     {$I SPortUtil.inc}
  49.  
  50.     begin
  51.         if paramPtr^.paramCount <> 1 then Fail('parameter count is not 1');
  52.  
  53.         SetUpSPortGlobals;
  54.         EnsureOpenPort;
  55.  
  56.         GetStrParm(1,inOutBoth);
  57.  
  58.         if StringEqual(paramPtr,inOutBoth,'in') or StringEqual(paramPtr,inOutBoth,'both') then
  59.             begin
  60.                 if KillIO(ThisSPort.portInDev) <> noErr then Fail('KillIO failed');
  61.             end;
  62.         if StringEqual(paramPtr,inOutBoth,'out') or StringEqual(paramPtr,inOutBoth,'both') then
  63.             begin
  64.                 if KillIO(ThisSPort.portOutDev) <> noErr then Fail('KillIO failed');
  65.             end;
  66.     end;
  67.  
  68. end.
  69.